feat: add user reputation dashboard with XP, skills radar, and contri…#169
Conversation
…bution heatmap - Extend reputation types with XP, skills, and contribution history fields - Create skill radar chart component using Recharts - Create GitHub-style contribution heatmap with streak tracking - Add XP display widget with level progression - Add reputation dashboard tab to profile page - Handle empty states gracefully for all components Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|
@legend4tech is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
|
@legend4tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 56 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughIntroduces a Reputation Dashboard feature with new visualization components (XP display, skill radar chart, contribution heatmap) integrated into the profile page. Extends reputation types with metrics structure, updates the profile page to include the new dashboard tab, refactors notification hook initialization, and reformats contract helpers. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/profile/`[userId]/page.tsx:
- Around line 235-239: The code force-casts reputation to
ContributorReputationWithMetrics when rendering <ReputationDashboard>, which can
crash if the API returned ContributorReputation without metrics; instead, check
for reputation.metrics before casting and handle the missing-metrics case
gracefully—either render a fallback/placeholder UI or pass default metrics
(e.g., zeros) so ReputationDashboard always receives the expected shape; update
the prop handling in ReputationDashboard usage (or its prop type) to accept
ContributorReputation | ContributorReputationWithMetrics and guard/use default
values when metrics is undefined.
In `@components/profile/contribution-heatmap.tsx`:
- Line 12: Remove the unused import and parameter to fix lint warnings: delete
the unused named import isSameDay from the top import list and remove the unused
map callback parameter index (or rename it to _ if needed) in the component's
map/iteration where index is defined so both symbols are no longer unused;
ensure any logic relying on isSameDay is preserved or replaced with the used
utilities (format, subDays, startOfDay) and run the linter to confirm warnings
are resolved.
- Around line 151-169: The current month labels use the static MONTHS array and
can misalign with the actual 365-day heatmap; instead compute monthLabels from
the rendered weeks array: iterate over weeks (use each week’s first real day or
first non-null day), derive its month name/index, and only emit a label when the
month changes or at the first/last week; replace the static MONTHS usage in the
render block with the computed monthLabels so labels align with week columns
(refer to symbols weeks, monthLabels, and MONTHS in contribution-heatmap.tsx).
In `@components/profile/xp-display.tsx`:
- Around line 14-19: getLevelFromXp currently computes level/progress directly
from xp which allows negative xp to produce invalid results; clamp or normalize
xp to be non-negative at the top of getLevelFromXp (e.g., const safeXp =
Math.max(0, xp)) and then use safeXp for computing level, currentLevelXp,
nextLevelXp and progress so level, currentLevelXp and progress are always valid.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4102b51e-7690-4e95-8068-26ace6d84f11
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
app/profile/[userId]/page.tsxcomponents/profile/contribution-heatmap.tsxcomponents/profile/reputation-dashboard.tsxcomponents/profile/skill-radar-chart.tsxcomponents/profile/xp-display.tsxtypes/reputation.ts
There was a problem hiding this comment.
Hi @legend4tech , There are a few things I'd like to request changes on before we can merge this.
-
First, there's a critical issue in
app/profile/[userId]/page.tsxwhere reputation is cast toContributorReputationWithMetricsusing as, but the API actually returnsContributorReputationwhich doesn't include a metrics field — this will cause a runtime crash when accessingmetrics.xp, metrics.skills,etc. Please add propernull/undefinedguards or update the API client to return the extended type, and use mock data for testing the dashboard components until the backend supports the full metrics payload. -
Second, please address the CodeRabbit feedback — specifically the docstring coverage warning — and also fix the unused
isSameDayimport in contribution-heatmap.tsx, the misaligned static month labels in theheatmap grid, and the O(n*m)performance issue in the contribution lookup loop (use a Map instead of.find()inside the 365-day iteration). -
Also fix CI failures
- Fix unsafe cast in profile page by adding metrics type guard and mock data fallback - Remove unused isSameDay import and index variable in contribution-heatmap - Fix static month labels to derive chronologically from actual week data - Optimize contribution lookup from O(n*m) to O(n) using Map instead of .find() - Add negative XP guard in xp-display to clamp values to 0 - Remove unused useRef import in bounty-detail-submissions-card - Remove unused waitFor import in use-submission-draft test - Fix setState in effect error in use-notifications using lazy initialization Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Replace setState in effect with lazy initializer to satisfy react-hooks/set-state-in-effect lint rule Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|
@Benjtalkshow u can merge |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/profile/[userId]/page.tsx (1)
266-279: Consider collapsing the two render branches into one computed value.You can compute a single
dashboardReputationobject before JSX and render<ReputationDashboard />once. This reduces duplication and keeps future prop changes safer.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/profile/`[userId]/page.tsx around lines 266 - 279, Compute a single dashboardReputation before the JSX and render <ReputationDashboard /> only once: create a const (e.g., dashboardReputation) that uses the existing reputation value and, if it lacks metrics, spreads reputation and sets metrics: getMockMetrics(); then replace the two conditional render branches inside <TabsContent> with a single <ReputationDashboard reputation={dashboardReputation} />. Refer to the existing symbols reputation, getMockMetrics(), ReputationDashboard and the ContributorReputationWithMetrics shape when implementing this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/profile/`[userId]/page.tsx:
- Around line 27-40: The getMockMetrics function currently returns fabricated XP
and skill levels; replace those synthetic values with neutral fallbacks
(zeros/empty arrays) and change any UI that consumes
ContributorReputationWithMetrics["metrics"] to treat this fallback as “metrics
unavailable” (e.g., show a placeholder or a “metrics not available yet” state)
instead of rendering performance data; locate getMockMetrics and update its xp
to 0, skills to an empty array, and contributionHistory to zero/empty values,
and ensure the profile/[userId]/page.tsx render path checks for the neutral
fallback and displays the unavailable-state UI rather than synthetic metrics.
---
Nitpick comments:
In `@app/profile/`[userId]/page.tsx:
- Around line 266-279: Compute a single dashboardReputation before the JSX and
render <ReputationDashboard /> only once: create a const (e.g.,
dashboardReputation) that uses the existing reputation value and, if it lacks
metrics, spreads reputation and sets metrics: getMockMetrics(); then replace the
two conditional render branches inside <TabsContent> with a single
<ReputationDashboard reputation={dashboardReputation} />. Refer to the existing
symbols reputation, getMockMetrics(), ReputationDashboard and the
ContributorReputationWithMetrics shape when implementing this change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 050b0f64-4175-4497-bca4-d003d5dd8482
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
app/profile/[userId]/page.tsxlib/contracts/index.tslib/contracts/transaction.ts
✅ Files skipped from review due to trivial changes (2)
- lib/contracts/transaction.ts
- lib/contracts/index.ts
- Remove fabricated XP/skills mock data that could mislead users - Show 'metrics not available yet' placeholder state instead - Rename getMockMetrics to getEmptyMetrics and simplify to zeros/empty arrays - Display informative message when backend doesn't support extended metrics Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Committed and pushed successfully. Here’s a brief PR description you can copy:
Feature: User Reputation Dashboard
Overview
Adds a visual reputation dashboard to user profiles showcasing XP, technical skills, and contribution activity.
Changes
types/reputation.tswithSkillLevel,ContributionHistory, andUserReputationMetricsTesting
Closes #132
Summary by CodeRabbit
Release Notes